﻿using UnityEngine;
using System.Collections;

public class BulletController : MonoBehaviour {


    public int chooseMoveBullet;
    public float Speed;
    public GameObject tempObject;

    public float damage { get;  set; }
    void Awake()
    {

        
    }
    void FixedUpdate()
    {
        Debug.Log(damage);
        switch (chooseMoveBullet)
        {
            case 1:
                rigidbody.velocity = transform.right * Speed;
                break;
            case 2:

                rigidbody.velocity = transform.up * Speed;
                break;
        }
    }

    void OnTriggerEnter(Collider other)
    {
        if (other.tag == Tags.enemy)
        {
            EnemyController enemy = other.GetComponent<EnemyController>();
            if (gameObject.tag == Tags.bulletPlayer)
            {
                enemy.Hurt(damage);
                Destroy(gameObject);
            }
        }
        else if (other.tag == Tags.player)
        {
            PlayerController player= other.GetComponent<PlayerController>();
            if (gameObject.tag == Tags.bulletEnemy)
            {
                player.Hurt(damage);
                Destroy(gameObject);
            }
        }

       

        
    }

   
    
}
